#include "src/parser/sql_parser.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

const char* test_cases[] = {
    "CREATE DATABASE test_db;",
    "CREATE DATABASE IF NOT EXISTS test_db;",
    "create database my_database;",
    "CREATE DATABASE 123invalid;",
    NULL
};

int main() {
    printf("=== CREATE DATABASE Parser Test ===\n\n");
    
    for (int i = 0; test_cases[i] != NULL; i++) {
        printf("%d. Testing: %s\n", i + 1, test_cases[i]);
        
        parser_t* parser = parser_create(test_cases[i]);
        if (!parser) {
            printf("   ❌ Failed to create parser\n");
            continue;
        }
        
        statement_t* stmt = parser_parse_statement(parser);
        if (!stmt) {
            printf("   ❌ Parse failed: %s\n", 
                   parser_get_error(parser) ? parser_get_error(parser) : "Unknown error");
        } else {
            printf("   ✅ Successfully parsed as STMT_CREATE_DATABASE\n");
            printf("   🔍 Database name: %s\n", stmt->data.create_database.database_name);
            printf("   🔍 IF NOT EXISTS: %s\n", stmt->data.create_database.if_not_exists ? "true" : "false");
            statement_destroy(stmt);
        }
        
        parser_destroy(parser);
        printf("\n");
    }
    
    return 0;
}